<?php

use yii\widgets\ActiveForm;
use yii\widgets\LinkPager;
use common\helpers\Url;
use common\helpers\Html;

$this->title = '杠杆合约';
$this->params['breadcrumbs'][] = ['label' => $this->title];
?>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title"><?= $this->title; ?></h3>

                <div class="col-sm-12" style="margin-top: 10px;">
                    <?php $form = ActiveForm::begin([
                        'action' => Url::to(['index']),
                        'method' => 'get',
                    ]); ?>

                    <div class="col-sm-3">
                        <div class="input-group">

                            <?= Html::textInput('keyword', $keyword, [
                                'class' => 'form-control',
                                'id' => 'test-input',
                                'placeholder' => '请输入要查询的用户名或手机号',
                            ]) ?>

                        </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="input-group">

                            <?= Html::dropDownList('type', NULL, $typeArray, [
                                'options' => [$type => ['selected' => TRUE]],
                                'prompt' => '请选择',
                                'class' => 'form-control',
                            ]) ?>


                            <span class="input-group-btn"><button class="btn btn-white"><i
                                            class="fa fa-search"></i> 搜索</button></span>
                        </div>
                    </div>

                    <?php ActiveForm::end(); ?>

                </div>
            </div>
            <div class="box-body table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>用户名</th>
                        <th>杠杆类型</th>
                        <th>配资金额</th>
                        <th>申请金额</th>
                        <th>开始日期</th>
                        <th>结束日期</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($models as $key => $model) { ?>
                        <tr id= <?= $model->id; ?>>
                            <td><?= $key + 1; ?></td>
                            <td><?= $model->member->username; ?></td>
                            <td><?= $model->lever->name; ?></td>
                            <td><?= $model->price; ?></td>
                            <td><?= $model->price_lever; ?></td>
                            <td><?= $model->sdate; ?></td>
                            <td><?= $model->edate; ?></td>
                            <td><?= $model->state; ?></td>
                            <td>
                                <?php if ($model->state == '审核中'): ?>
                                    <?= Html::a('通过', ['status', 'id' => $model->id, 'status' => '正常'], [
                                        'class' => 'btn btn-success btn-sm'
                                    ]); ?>

                                    <?= Html::a('驳回', ['status', 'id' => $model->id, 'status' => '未通过'], [
                                        'class' => 'btn btn-warning btn-sm'
                                    ]); ?>
                                <?php endif; ?>
                                <?= Html::delete(['delete', 'id' => $model->id]); ?>
                            </td>
                        </tr>
                    <?php } ?>
                    </tbody>
                </table>
            </div>
            <div class="box-footer">
                <?= LinkPager::widget([
                    'pagination' => $pages
                ]); ?>
            </div>
        </div>
    </div>
</div>